<? session_start();
						
include_once ('core/conn.php');
						
$db = get_conn();
						
check_session();
						
if($_GET['id'] != ''){
							
	$sql = " select * from invoices where id_invoice=".$_GET['id']; 
							
	$result = mysql_query($sql);	
							
	if($result){
								
		$row = mysql_fetch_array($result);
		$id_invoice = $row['id_invoice'];
		$id_location = $row['id_location'];
		$id_it = $row['id_it'];
		$amount = $row['amount'];
		$due_date = $row['due_date'];
		$exp_date = $row['exp_date'];
		$description = $row['description'];
		$istatus = $row['istatus'];
		
		$filter = $id_location;
		
		$comments = $row['description'];	
		if($comments  ==''){
			$comments = "Ninguno";
		}		
							
	}else{
								
		error_handling($sql,mysql_error());
							
	}
						
}
						
						
					
?>
					
					
<html>
					
<head>
<script src="tools/jq_dp/js/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="tools/jq_dp/js/jquery-ui-1.8.11.custom.min.js" type="text/javascript"></script>
<link href="css/demos.css" rel="stylesheet" type="text/css" />
<script src="js/misc.js" type="text/javascript"></script>					
<script>
					
<!--
						
	function checkdata(obj){
							
		if(obj.description.value ==''){
			alert('Debe indicar el # de documento');
			obj.description.focus();
			return false;
		}		

		return true;
						
	}
	



	$(function() {
		$( "#due_date" ).datepicker();
		$( "#exp_date" ).datepicker();
		
	});





-->
</script>					
</head>									
					
<body>														
				
				
<form action='/core/invoices.php' method='post' enctype="multipart/form-data" name='invoices' onsubmit='return checkdata(this)'>
  <table width='54%' border='0'>
    <tr>
      <td colspan="2" align='left' nowrap>Reporte de Pago</td>
    </tr>
    <tr>
      <td width="13%" align='left' nowrap>Tipo de Cobro:</td>
      <td align='left'>
        <?php

	  echo get_invoice_type_name($id_it)
	  ?>
        <input type="hidden" name="id_invoice" id="id_invoice" value="<?php echo $id_invoice?>">
        <input type="hidden" name="id_location" id="id_location" value="<?php echo $id_location?>">
        <input type="hidden" name="amount" id="amount" value="<?php echo $amount?>"></td>
    </tr>
    <tr>
      <td align='left' nowrap>Al cobro desde:</td>
      <td align='left'><?php echo $due_date?></td>
    </tr>
    <tr>
      <td align='left' nowrap>Fecha Vencimiento:</td>
      <td align='left'><?php echo $exp_date?></td>
    </tr>
    <tr>
      <td align='left' nowrap>Monto:</td>
      <td align='left' nowrap><?php echo format($amount,2)?></td>
    </tr>
    <tr>
      <td align='left' nowrap>Comentarios:</td>
      <td align='left' nowrap><?php echo $comments?></td>
    </tr>
    <tr>
      <td align='left' nowrap># de documento:</td>
      <td align='left' nowrap><input name="description" type="text" id="description" value="" size="30"></td>
    </tr>
    <tr>
      <td align='left' nowrap>Recibo Digital</td>
      <td align='left' nowrap><input type="file" name="recibo" id="recibo"></td>
    </tr>
    <tr>
      <td align='left' nowrap>&nbsp;</td>
      <td align='left' nowrap>&nbsp;</td>
    </tr>
    <tr>
      <td align='left' colspan="2" nowrap><input type="submit" name="report_payment" id="report_payment" value="Reportar pago">
      <input type='button' name='quick_add2' value='Cancelar' onClick='parent.$.modal().close();'  /></td>
    </tr>
  </table>
</form>
					
</body></html>

<?php

	function get_invoice_type_name($id_it){
		if($id_it !=''){
			$sql = "select name from invoices_type where id_it=".$id_it;
			$result = mysql_query($sql);
			if($result){
				$row = mysql_fetch_array($result);
				return $row['name'];	
			}else{
				error_handling(__FUNCTION__." ".$sql,mysql_error());
			}		
		}		
	}
?>